// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:hi_flutter/app_page.dart';

class AnimatePage1 extends StatefulWidget {
  const AnimatePage1({Key? key}) : super(key: key);

  @override
  AnimatePage1State createState() => AnimatePage1State();
}

class AnimatePage1State extends State<AnimatePage1> with SingleTickerProviderStateMixin {
  late Animation<double> animation;
  late AnimationController controller;

  @override
  initState() {
    super.initState();
    controller = AnimationController(
        duration: const Duration(milliseconds: 2000),
        vsync: this
    );
    animation = Tween(begin: 0.0, end: 300.0).animate(controller)
      ..addListener(() {
        setState(() {
          // the state that has changed here is the animation object’s value
        });
      });
    controller.forward();
  }

  @override
  Widget build(BuildContext context) {
    return AppPage(
      body: Center(
        child: Container(
          margin: const EdgeInsets.symmetric(vertical: 10.0),
          height: animation.value,
          width: animation.value,
          child: const FlutterLogo(),
        ),
      ),
    );
  }

  @override
  dispose() {
    controller.dispose();
    super.dispose();
  }
}
